package markgame2dphys;

import java.awt.Color;

import net.phys2d.math.Vector2f;
import net.phys2d.raw.DistanceJoint;

public class MarkGameDistanceJoint extends MarkGameJoint{

	public DistanceJoint joint;

	public MarkGameDistanceJoint(MarkGameObject obj1, MarkGameObject obj2, Vector2f anchor1, Vector2f anchor2, float distance) {

		super(new DistanceJoint(obj1.body, obj2.body, anchor1, anchor2, distance));
		//TODO adicionar restitution
		joint = (DistanceJoint)super.joint;
	}

	public void paint(MarkGameGraphics g) {

		int r = 2;

		g.setColor(Color.RED);

		Vector2f anchor1 = MarkGameUtils.convertLocalToGlobal(joint.getBody1(), (Vector2f)joint.getAnchor1());
		g.drawCircle(anchor1, r);

		Vector2f anchor2 = MarkGameUtils.convertLocalToGlobal(joint.getBody2(), (Vector2f)joint.getAnchor2());
		g.drawCircle(anchor2, r);

		g.drawLine(anchor1, anchor2);

	}


}
